package cn.edu.scau.cmi.wujiaxian.exercise10;

import java.io.IOException;
import java.io.RandomAccessFile;

public class Example10_8 {
	
	public static void main(String[] args) {
		RandomAccessFile io = null;
		int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		try {
			io = new RandomAccessFile("tom.dat", "rw");
			for (int i = 0; i < data.length; i++) {
				io.writeInt(data[i]);
			}
			for (long i = data.length - 1; i >= 0; i--) {
				io.seek(i * 4);
				System.out.println(io.readInt());
			}
			io.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
	
}
